package com.management.service.impl;

import com.management.commons.exception.CreateAttachException;
import com.management.commons.exception.ExceptionCode.AttachExceptionCode;
import com.management.model.Attach;
import com.management.dao.AttachDao;
import com.management.service.AttachService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.management.utils.Result;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 龙世超
 * @since 2022-03-23
 */
@Service
public class AttachServiceImpl extends ServiceImpl<AttachDao, Attach> implements AttachService {

    @Override
    public Result AddAttach(Attach attach) {

        int insert = baseMapper.insert(attach);
        if (insert>0) {
            return Result.getInstance().setMessage("新增成功").setData(attach.getAttachId());
        }
        throw new CreateAttachException(AttachExceptionCode.CREATEATTACH_ERROR);
    }
}
